home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / M / May MacUser Program.cpt / miniGenApp Src / AboutBox.c next >
Encoding:
C/C++ Source or Header  |  1990-03-29  |  3.8 KB  |  165 lines  |  [TEXT/KAHL]

  1. /* *****************************************************************************
  2.     FILE:             AboutBox.c
  3.     
  4.     DESCRIPTION:     AboutBox utilities
  5.  
  6.     AUTHOR:            Kurt W.G. Matthies
  7.         
  8.     Copyright © 1990 by Code of the West, Inc. All Rights Reserved.
  9.  
  10.     
  11.     Revision History:
  12.     ==========================================================
  13.     3.30.90    -    May 1990 MacUser Release
  14.     ==========================================================
  15.  
  16.    ***************************************************************************** */
  17. #include "Version.h"
  18.  
  19. #ifdef V4
  20. #include <stdio.h>
  21. #endif
  22.  
  23. #ifdef V3
  24. #include <Proto.h>
  25. #endif
  26.  
  27. #ifdef V2
  28. #include <Proto.h>
  29. #include <Pascal.h>
  30. #endif
  31.  
  32. #include "AppConstants.h"
  33. #include "DialogUtilPr.h"
  34. #include "WindowUtilPr.h"
  35.  
  36. #include "AboutBoxPr.h"
  37.  
  38. /* ---------------------------  Local Prototypes  ----------------------------- */
  39.  
  40. DialogPtr    drawAboutBox ( Boolean );
  41.  
  42. /* ----------------------------------------------------------------------------
  43.     doAboutBox -    put up about box, wait for user to go away
  44.     3.30.90kwgm
  45. ------------------------------------------------------------------------------- */
  46. void 
  47. doAboutBox ()
  48. {
  49.     EventRecord            theEvent;
  50.     DialogPtr            theDialog;
  51.     GrafPtr                savePort;
  52.     
  53.     GetPort (&savePort);
  54.  
  55.     if (theDialog = drawAboutBox (true))
  56.     {
  57.         /* wait for a key or mouse down */
  58.         while (!GetNextEvent (keyDownMask + mDownMask, &theEvent))
  59.             SystemTask();
  60.         
  61.         DisposDialog (theDialog);
  62.     }
  63.     
  64.     SetPort (savePort);
  65.  
  66. } /* doAboutBox */
  67.  
  68. /* ----------------------------------------------------------------------------
  69.     splashScreen -    put up about box, delay, go away automatically.
  70.     3.30.90kwgm        used to introduce the program.
  71. ------------------------------------------------------------------------------- */
  72. void 
  73. splashScreen ()
  74. {
  75.     EventRecord            theEvent;
  76.     DialogPtr            theDialog;
  77.     GrafPtr                savePort;
  78.     long                ticksNow;
  79.     
  80.     GetPort (&savePort);
  81.  
  82.     if (theDialog = drawAboutBox (false))
  83.     {
  84.     
  85.         Delay (120L, &ticksNow);    /* wait 120 ticks */
  86.         
  87.         DisposDialog (theDialog);
  88.     }
  89.     else
  90.     {
  91.         SysBeep (1);
  92.         ExitToShell ();        /* probably can't open resource fork! */
  93.     }
  94.     
  95.     SetPort (savePort);
  96.  
  97. } /* splashScreen */
  98.  
  99. /* -------------------------------------------------------------------------
  100.     drawAboutBox    -    do aboutbox display
  101.     3.30.90kwgm
  102. ---------------------------------------------------------------------------- */
  103. static DialogPtr
  104. drawAboutBox (doMemSize)
  105.     Boolean                doMemSize;
  106. {
  107.     register DialogPtr    theDialog;
  108.     ControlHandle        cntlHdl;
  109.     Size                sz;
  110.     short                itemType;
  111.     Rect                memBox;
  112.     char                memStr [64], formatStr [64];
  113.  
  114.     if (!(theDialog = GetNewDialog (kAboutBoxDLOG, 0L, -1L)))
  115.         return (0L);
  116.  
  117.     /* 
  118.         Developer's trick:
  119.         create your windows in ResEdit as invisible so that they can
  120.         be centered on the screen before they're displayed
  121.     */
  122.  
  123.     centerWindow (theDialog);
  124.  
  125.     /* now make it visible */
  126.     ShowHide (theDialog,true);
  127.     DrawDialog (theDialog);
  128.  
  129.     if (doMemSize)        /* print a total memory avail message in about box */
  130.     {
  131.         SetPort (theDialog);    /* set this dialog as the current grafport */
  132.  
  133.         /* memBox is location of where to draw string */
  134.         GetDItem (theDialog, kAboutMemBox, &itemType, &cntlHdl, &memBox);
  135.         
  136.         /* get the printf format string */
  137.         GetIndString (formatStr, kNameStrRsrc, kAboutBoxMsgStr);
  138.         PtoCstr (formatStr);
  139.         
  140.         /* create it */
  141.         sz = FreeMem ();
  142.         sprintf (memStr, formatStr, sz >> 10);
  143.         CtoPstr (memStr);
  144.     
  145.         /* draw it in white on black */
  146.         PenPat (white);
  147.         TextFont (1);        /* 12 pt 'appfont (usually geneva) */
  148.         TextSize (12);
  149.         TextMode (srcBic);    /* need this mode to 'lift' black pixels */
  150.         
  151.         MoveTo (memBox.left, memBox.bottom - 2);
  152.         DrawString (memStr);
  153.         
  154.         PenNormal ();
  155.     }
  156.     
  157.     return (theDialog);
  158.     
  159. } /* drawAboutBox */
  160.  
  161. /* ===============================  EOF  =======================================
  162.     Copyright © 1990 by Code of the West, Inc. All Rights Reserved.
  163. ================================================================================ */
  164.  
  165.